package com.example.wod.retrofitdemo;

import android.app.Application;

import com.example.wod.retrofitdemo.Util.SharePreferenceUtil;

/**
 * 作者：woodnaonly on 2016/3/10 09:17
 * 邮箱：497917264@qq.com
 */
public class App extends Application {
    private static App mApp;
    private static SharePreferenceUtil mSpUtil;

    public App() {
        mApp = this;
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    // 单例模式，才能及时返回数据

    public static final String PREFERENCE_NAME = "user_sharedinfo";

    public synchronized SharePreferenceUtil getSpUtil() {
        if (mSpUtil == null) {
            String sharedName = PREFERENCE_NAME;
            mSpUtil = new SharePreferenceUtil(this, sharedName);
        }
        return mSpUtil;
    }

    public static synchronized App getInstance() {
        if (mApp == null) {
            mApp = new App();
        }
        return mApp;
    }

}
